<template>
  <div>
    <header class="header">
      <h1>任务列表</h1>
      <input @keyup.enter="add()" v-model="todoname" class="new-todo" placeholder="请输入要做的事情" autofocus />
    </header>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        todoname:''
      }
    },
    methods: {
      add(){
        //方法 数据项如果写到js中  需要加this.  如果写在html中 就去掉this.
        this.$emit('add',this.todoname)
        this.todoname =''
      }
    },
  }
</script>

<style lang="scss" scoped>

</style>